package org.mics.organization.controller;

import javax.annotation.Resource;

import org.mics.core.page.PageQuery;
import org.mics.core.response.OneDataResponse;
import org.mics.core.response.PageDataResponse;
import org.mics.core.response.SimpleResponse;
import org.mics.organization.request.StaffRequest;
import org.mics.organization.service.StaffService;
import org.mics.organization.vo.StaffVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * 员工
 * @author mics
 * @date 2023-10-9
 * @version  1.0
 */
@RestController
@RequestMapping("/staff")
@Tag(name = "员工")
public class StaffController {
	@Resource
	private StaffService staffService;
	
	@Operation(summary =  "增加/修改员工")
    @RequestMapping(value = "/save",method = RequestMethod.POST)
	public SimpleResponse save(@Validated @RequestBody StaffRequest staffRequest ) {
		String id =   staffService.add(staffRequest);
		return new OneDataResponse<String>(id);
	}
	
	@Operation(summary =  "删除员工")
    @RequestMapping(value = "/delete/{id}",method = RequestMethod.DELETE)
	public SimpleResponse delete(@PathVariable("id") String id) {
		staffService.delete(id);
        return new SimpleResponse();
	}
	
	@Operation(summary =  "员工列表")
    @RequestMapping(value = "/listByPage",method = RequestMethod.POST)
	public PageDataResponse<StaffVO> listByPage(@RequestBody PageQuery pageQuery) {
		PageDataResponse<StaffVO> pageDataResponse =   staffService.listByPage(pageQuery);
		return pageDataResponse;
	}
}
